﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGeExtents2d : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGeExtents2d(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGeExtents2d obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGeExtents2d()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGeExtents2d(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public OdGeExtents2d() : this(GlobalsPINVOKE.new_OdGeExtents2d__SWIG_0(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeExtents2d(OdGePoint2d min, OdGePoint2d max) : this(GlobalsPINVOKE.new_OdGeExtents2d__SWIG_1(OdGePoint2d.getCPtr(min), OdGePoint2d.getCPtr(max)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePoint2d minPoint()
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGeExtents2d_minPoint(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d maxPoint()
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGeExtents2d_maxPoint(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void set(OdGePoint2d min, OdGePoint2d max)
		{
			GlobalsPINVOKE.OdGeExtents2d_set(this.swigCPtr, OdGePoint2d.getCPtr(min), OdGePoint2d.getCPtr(max));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void addPoint(OdGePoint2d point)
		{
			GlobalsPINVOKE.OdGeExtents2d_addPoint(this.swigCPtr, OdGePoint2d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void addExt(OdGeExtents2d extents)
		{
			GlobalsPINVOKE.OdGeExtents2d_addExt(this.swigCPtr, OdGeExtents2d.getCPtr(extents));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isValidExtents()
		{
			bool result = GlobalsPINVOKE.OdGeExtents2d_isValidExtents(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void expandBy(OdGeVector2d vect)
		{
			GlobalsPINVOKE.OdGeExtents2d_expandBy(this.swigCPtr, OdGeVector2d.getCPtr(vect).Handle);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void transformBy(OdGeMatrix2d xfm)
		{
			GlobalsPINVOKE.OdGeExtents2d_transformBy(this.swigCPtr, OdGeMatrix2d.getCPtr(xfm));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool contains(OdGePoint2d point)
		{
			bool result = GlobalsPINVOKE.OdGeExtents2d_contains__SWIG_0(this.swigCPtr, OdGePoint2d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool contains(OdGeExtents2d extents)
		{
			bool result = GlobalsPINVOKE.OdGeExtents2d_contains__SWIG_1(this.swigCPtr, OdGeExtents2d.getCPtr(extents));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isDisjoint(OdGeExtents2d extents)
		{
			bool result = GlobalsPINVOKE.OdGeExtents2d_isDisjoint(this.swigCPtr, OdGeExtents2d.getCPtr(extents));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeExtents2d.IntersectionStatus intersectWith(OdGeExtents2d extents, OdGeExtents2d pResult)
		{
			OdGeExtents2d.IntersectionStatus result = (OdGeExtents2d.IntersectionStatus)GlobalsPINVOKE.OdGeExtents2d_intersectWith__SWIG_0(this.swigCPtr, OdGeExtents2d.getCPtr(extents), OdGeExtents2d.getCPtr(pResult));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeExtents2d.IntersectionStatus intersectWith(OdGeExtents2d extents)
		{
			OdGeExtents2d.IntersectionStatus result = (OdGeExtents2d.IntersectionStatus)GlobalsPINVOKE.OdGeExtents2d_intersectWith__SWIG_1(this.swigCPtr, OdGeExtents2d.getCPtr(extents));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		public enum IntersectionStatus
		{
			kIntersectUnknown,
			kIntersectNot,
			kIntersectOpIn,
			kIntersectOpOut,
			kIntersectOk
		}
	}
}
